package cn.com.jonpad.demo06_simple_project.controller;

import cn.com.jonpad.demo06_simple_project.bean.LoginInfo;
import cn.com.jonpad.demo06_simple_project.bean.ResponseInfo;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

@RestController
public class LoginCtrl {

	@PostMapping("login")
	public ResponseInfo login(@RequestBody LoginInfo info, HttpSession session){
		ResponseInfo responseInfo = new ResponseInfo();
		responseInfo.setResponseBody(info);
		session.setAttribute("account",info.getAccount());
		return responseInfo;
	}

	@PostMapping("noLogin")
	public ResponseInfo noLogin(){
		ResponseInfo responseInfo = new ResponseInfo();
		responseInfo.setMessage("未登录");
		return responseInfo;
	}
}
